package com.example.jussi.helloworld;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class FirstActivity extends BaseActivity {

    Button button1;
    TextView textView1;

    public static void actionStart(Context context, String data){
        Intent intent = new Intent(context, FirstActivity.class);
        intent.putExtra("param", data);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_first);
        button1 = (Button) findViewById(R.id.button1);
        textView1 = (TextView) findViewById(R.id.textView1);

        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                HelloWorldActivity.actionStart(FirstActivity.this, "Hello World! ");
            }
        });

        Intent intent = getIntent();
        String param = intent.getStringExtra("param");
        if(!"".equals(param) && param != null){
            textView1.setText(param);
        }

    }

}
